<template>
  <div  class="img-view" @click="onClose" v-show="isShow">
    <img @click="onOpen"  class="img" :src="src" alt="">
    <Icon @click="onClose" class="icon-close" type="ios-close-circle-outline" />
  </div>
</template>
<script>
export default {
  props: {
    src: ''
  },
  data() {
    return {
      isShow: false
    }
  },
  mounted() {
    console.log(this.isShow)
  },
  methods: {
    onOpen(e) {
        try{
            e.stopPropagation();//非IE浏览器
        }
        catch(e){
            window.event.cancelBubble = true;//IE浏览器
        }
      this.isShow = true
    },
    onClose() {
      this.isShow = false
    }
  }
}
</script>
<style lang="less" scoped>
.img-view {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.3);
  z-index: 12;
  .img {
    width: 500px;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
  }
  .icon-close {
    width: 50px;
    height: 50px;
    position: absolute;
    right: 0;
    top: 30px;
    font-size: 50px;
    color: #fff;
  }
}
</style>